package Main1;
import java.util.Arrays;
import java.util.Scanner;

class PersonSortable implements Comparable<PersonSortable>{

	private String name;
	private int age;
	
	public PersonSortable(String name, int age) {
		this.name=name;
		this.age=age;
	}

	
	@Override
	public String toString() {
		return name+"-"+age;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public int getAge() {
		return age;
	}


	public void setAge(int age) {
		this.age = age;
	}


	@Override
	public int compareTo(PersonSortable o) {
		if(this.name.compareTo(o.getName())>0)
			return 1;
		if(this.name.compareTo(o.getName())<0)
			return -1;
		if(this.age>o.getAge())
			return 1;
		if(this.age<o.getAge())
			return -1;
		return 0;
		
	}
	
	
	
}
public class Main1 {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in 

);
 		int n =sc.nextInt();
 		PersonSortable[] person = new PersonSortable[n];
 		for(int i=0;i<person.length;i++){
 			person[i] = new PersonSortable(sc.next(),sc.nextInt());
 		}
 		Arrays.sort(person);
 		for (int i = 0; i < person.length; i++) {
 			System.out.println(person[i]);
		}
 		System.out.println(Arrays.toString(PersonSortable.class.getInterfaces()));
	}
}
